/* eslint-disable */
import _m0 from "protobufjs/minimal";
import { FieldMask } from "../../google/protobuf/field_mask";
import { Timestamp } from "../../google/protobuf/timestamp";
import { Visibility } from "./common";

export const protobufPackage = "slash.api.v1";

export interface Collection {
  id: number;
  parentId: number;
  type: string;
  creatorId: number;
  createdTime: Date | undefined;
  updatedTime: Date | undefined;
  name: string;
  title: string;
  description: string;
  shortcutIds: number[];
  visibility: Visibility;
}

export interface ListCollectionsRequest {
}

export interface ListCollectionsResponse {
  collections: Collection[];
}

export interface GetCollectionRequest {
  id: number;
}

export interface GetCollectionResponse {
  collection: Collection | undefined;
}

export interface GetCollectionByNameRequest {
  name: string;
}

export interface GetCollectionByNameResponse {
  collection: Collection | undefined;
}

export interface CreateCollectionRequest {
  collection: Collection | undefined;
}

export interface CreateCollectionResponse {
  collection: Collection | undefined;
}

export interface UpdateCollectionRequest {
  collection: Collection | undefined;
  updateMask: string[] | undefined;
}

export interface UpdateCollectionResponse {
  collection: Collection | undefined;
}

export interface DeleteCollectionRequest {
  id: number;
}

export interface DeleteCollectionResponse {
}

function createBaseCollection(): Collection {
  return {
    id: 0,
    parentId: 0,
    type: "",
    creatorId: 0,
    createdTime: undefined,
    updatedTime: undefined,
    name: "",
    title: "",
    description: "",
    shortcutIds: [],
    visibility: 0,
  };
}

export const Collection = {
  encode(message: Collection, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.id !== 0) {
      writer.uint32(8).int32(message.id);
    }
    if (message.parentId !== 0) {
      writer.uint32(16).int32(message.parentId);
    }
    if (message.type !== "") {
      writer.uint32(26).string(message.type);
    }
    if (message.creatorId !== 0) {
      writer.uint32(32).int32(message.creatorId);
    }
    if (message.createdTime !== undefined) {
      Timestamp.encode(toTimestamp(message.createdTime), writer.uint32(42).fork()).ldelim();
    }
    if (message.updatedTime !== undefined) {
      Timestamp.encode(toTimestamp(message.updatedTime), writer.uint32(50).fork()).ldelim();
    }
    if (message.name !== "") {
      writer.uint32(58).string(message.name);
    }
    if (message.title !== "") {
      writer.uint32(66).string(message.title);
    }
    if (message.description !== "") {
      writer.uint32(74).string(message.description);
    }
    writer.uint32(82).fork();
    for (const v of message.shortcutIds) {
      writer.int32(v);
    }
    writer.ldelim();
    if (message.visibility !== 0) {
      writer.uint32(88).int32(message.visibility);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): Collection {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseCollection();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.id = reader.int32();
          continue;
        case 2:
          if (tag !== 16) {
            break;
          }

          message.parentId = reader.int32();
          continue;
        case 3:
          if (tag !== 26) {
            break;
          }

          message.type = reader.string();
          continue;
        case 4:
          if (tag !== 32) {
            break;
          }

          message.creatorId = reader.int32();
          continue;
        case 5:
          if (tag !== 42) {
            break;
          }

          message.createdTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
          continue;
        case 6:
          if (tag !== 50) {
            break;
          }

          message.updatedTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
          continue;
        case 7:
          if (tag !== 58) {
            break;
          }

          message.name = reader.string();
          continue;
        case 8:
          if (tag !== 66) {
            break;
          }

          message.title = reader.string();
          continue;
        case 9:
          if (tag !== 74) {
            break;
          }

          message.description = reader.string();
          continue;
        case 10:
          if (tag === 80) {
            message.shortcutIds.push(reader.int32());

            continue;
          }

          if (tag === 82) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.shortcutIds.push(reader.int32());
            }

            continue;
          }

          break;
        case 11:
          if (tag !== 88) {
            break;
          }

          message.visibility = reader.int32() as any;
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<Collection>): Collection {
    return Collection.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<Collection>): Collection {
    const message = createBaseCollection();
    message.id = object.id ?? 0;
    message.parentId = object.parentId ?? 0;
    message.type = object.type ?? "";
    message.creatorId = object.creatorId ?? 0;
    message.createdTime = object.createdTime ?? undefined;
    message.updatedTime = object.updatedTime ?? undefined;
    message.name = object.name ?? "";
    message.title = object.title ?? "";
    message.description = object.description ?? "";
    message.shortcutIds = object.shortcutIds?.map((e) => e) || [];
    message.visibility = object.visibility ?? 0;
    return message;
  },
};

function createBaseListCollectionsRequest(): ListCollectionsRequest {
  return {};
}

export const ListCollectionsRequest = {
  encode(_: ListCollectionsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): ListCollectionsRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseListCollectionsRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<ListCollectionsRequest>): ListCollectionsRequest {
    return ListCollectionsRequest.fromPartial(base ?? {});
  },

  fromPartial(_: DeepPartial<ListCollectionsRequest>): ListCollectionsRequest {
    const message = createBaseListCollectionsRequest();
    return message;
  },
};

function createBaseListCollectionsResponse(): ListCollectionsResponse {
  return { collections: [] };
}

export const ListCollectionsResponse = {
  encode(message: ListCollectionsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    for (const v of message.collections) {
      Collection.encode(v!, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): ListCollectionsResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseListCollectionsResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.collections.push(Collection.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<ListCollectionsResponse>): ListCollectionsResponse {
    return ListCollectionsResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<ListCollectionsResponse>): ListCollectionsResponse {
    const message = createBaseListCollectionsResponse();
    message.collections = object.collections?.map((e) => Collection.fromPartial(e)) || [];
    return message;
  },
};

function createBaseGetCollectionRequest(): GetCollectionRequest {
  return { id: 0 };
}

export const GetCollectionRequest = {
  encode(message: GetCollectionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.id !== 0) {
      writer.uint32(8).int32(message.id);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetCollectionRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetCollectionRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.id = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetCollectionRequest>): GetCollectionRequest {
    return GetCollectionRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetCollectionRequest>): GetCollectionRequest {
    const message = createBaseGetCollectionRequest();
    message.id = object.id ?? 0;
    return message;
  },
};

function createBaseGetCollectionResponse(): GetCollectionResponse {
  return { collection: undefined };
}

export const GetCollectionResponse = {
  encode(message: GetCollectionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.collection !== undefined) {
      Collection.encode(message.collection, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetCollectionResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetCollectionResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.collection = Collection.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetCollectionResponse>): GetCollectionResponse {
    return GetCollectionResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetCollectionResponse>): GetCollectionResponse {
    const message = createBaseGetCollectionResponse();
    message.collection = (object.collection !== undefined && object.collection !== null)
      ? Collection.fromPartial(object.collection)
      : undefined;
    return message;
  },
};

function createBaseGetCollectionByNameRequest(): GetCollectionByNameRequest {
  return { name: "" };
}

export const GetCollectionByNameRequest = {
  encode(message: GetCollectionByNameRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.name !== "") {
      writer.uint32(10).string(message.name);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetCollectionByNameRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetCollectionByNameRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.name = reader.string();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetCollectionByNameRequest>): GetCollectionByNameRequest {
    return GetCollectionByNameRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetCollectionByNameRequest>): GetCollectionByNameRequest {
    const message = createBaseGetCollectionByNameRequest();
    message.name = object.name ?? "";
    return message;
  },
};

function createBaseGetCollectionByNameResponse(): GetCollectionByNameResponse {
  return { collection: undefined };
}

export const GetCollectionByNameResponse = {
  encode(message: GetCollectionByNameResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.collection !== undefined) {
      Collection.encode(message.collection, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetCollectionByNameResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetCollectionByNameResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.collection = Collection.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetCollectionByNameResponse>): GetCollectionByNameResponse {
    return GetCollectionByNameResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetCollectionByNameResponse>): GetCollectionByNameResponse {
    const message = createBaseGetCollectionByNameResponse();
    message.collection = (object.collection !== undefined && object.collection !== null)
      ? Collection.fromPartial(object.collection)
      : undefined;
    return message;
  },
};

function createBaseCreateCollectionRequest(): CreateCollectionRequest {
  return { collection: undefined };
}

export const CreateCollectionRequest = {
  encode(message: CreateCollectionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.collection !== undefined) {
      Collection.encode(message.collection, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): CreateCollectionRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseCreateCollectionRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.collection = Collection.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<CreateCollectionRequest>): CreateCollectionRequest {
    return CreateCollectionRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<CreateCollectionRequest>): CreateCollectionRequest {
    const message = createBaseCreateCollectionRequest();
    message.collection = (object.collection !== undefined && object.collection !== null)
      ? Collection.fromPartial(object.collection)
      : undefined;
    return message;
  },
};

function createBaseCreateCollectionResponse(): CreateCollectionResponse {
  return { collection: undefined };
}

export const CreateCollectionResponse = {
  encode(message: CreateCollectionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.collection !== undefined) {
      Collection.encode(message.collection, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): CreateCollectionResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseCreateCollectionResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.collection = Collection.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<CreateCollectionResponse>): CreateCollectionResponse {
    return CreateCollectionResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<CreateCollectionResponse>): CreateCollectionResponse {
    const message = createBaseCreateCollectionResponse();
    message.collection = (object.collection !== undefined && object.collection !== null)
      ? Collection.fromPartial(object.collection)
      : undefined;
    return message;
  },
};

function createBaseUpdateCollectionRequest(): UpdateCollectionRequest {
  return { collection: undefined, updateMask: undefined };
}

export const UpdateCollectionRequest = {
  encode(message: UpdateCollectionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.collection !== undefined) {
      Collection.encode(message.collection, writer.uint32(10).fork()).ldelim();
    }
    if (message.updateMask !== undefined) {
      FieldMask.encode(FieldMask.wrap(message.updateMask), writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): UpdateCollectionRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseUpdateCollectionRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.collection = Collection.decode(reader, reader.uint32());
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }

          message.updateMask = FieldMask.unwrap(FieldMask.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<UpdateCollectionRequest>): UpdateCollectionRequest {
    return UpdateCollectionRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<UpdateCollectionRequest>): UpdateCollectionRequest {
    const message = createBaseUpdateCollectionRequest();
    message.collection = (object.collection !== undefined && object.collection !== null)
      ? Collection.fromPartial(object.collection)
      : undefined;
    message.updateMask = object.updateMask ?? undefined;
    return message;
  },
};

function createBaseUpdateCollectionResponse(): UpdateCollectionResponse {
  return { collection: undefined };
}

export const UpdateCollectionResponse = {
  encode(message: UpdateCollectionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.collection !== undefined) {
      Collection.encode(message.collection, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): UpdateCollectionResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseUpdateCollectionResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.collection = Collection.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<UpdateCollectionResponse>): UpdateCollectionResponse {
    return UpdateCollectionResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<UpdateCollectionResponse>): UpdateCollectionResponse {
    const message = createBaseUpdateCollectionResponse();
    message.collection = (object.collection !== undefined && object.collection !== null)
      ? Collection.fromPartial(object.collection)
      : undefined;
    return message;
  },
};

function createBaseDeleteCollectionRequest(): DeleteCollectionRequest {
  return { id: 0 };
}

export const DeleteCollectionRequest = {
  encode(message: DeleteCollectionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.id !== 0) {
      writer.uint32(8).int32(message.id);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): DeleteCollectionRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseDeleteCollectionRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.id = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<DeleteCollectionRequest>): DeleteCollectionRequest {
    return DeleteCollectionRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<DeleteCollectionRequest>): DeleteCollectionRequest {
    const message = createBaseDeleteCollectionRequest();
    message.id = object.id ?? 0;
    return message;
  },
};

function createBaseDeleteCollectionResponse(): DeleteCollectionResponse {
  return {};
}

export const DeleteCollectionResponse = {
  encode(_: DeleteCollectionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): DeleteCollectionResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseDeleteCollectionResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<DeleteCollectionResponse>): DeleteCollectionResponse {
    return DeleteCollectionResponse.fromPartial(base ?? {});
  },

  fromPartial(_: DeepPartial<DeleteCollectionResponse>): DeleteCollectionResponse {
    const message = createBaseDeleteCollectionResponse();
    return message;
  },
};

export type CollectionServiceDefinition = typeof CollectionServiceDefinition;
export const CollectionServiceDefinition = {
  name: "CollectionService",
  fullName: "slash.api.v1.CollectionService",
  methods: {
    /** ListCollections returns a list of collections. */
    listCollections: {
      name: "ListCollections",
      requestType: ListCollectionsRequest,
      requestStream: false,
      responseType: ListCollectionsResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          578365826: [
            new Uint8Array([
              21,
              18,
              19,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              99,
              111,
              108,
              108,
              101,
              99,
              116,
              105,
              111,
              110,
              115,
            ]),
          ],
        },
      },
    },
    /** GetCollection returns a collection by id. */
    getCollection: {
      name: "GetCollection",
      requestType: GetCollectionRequest,
      requestStream: false,
      responseType: GetCollectionResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          8410: [new Uint8Array([2, 105, 100])],
          578365826: [
            new Uint8Array([
              26,
              18,
              24,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              99,
              111,
              108,
              108,
              101,
              99,
              116,
              105,
              111,
              110,
              115,
              47,
              123,
              105,
              100,
              125,
            ]),
          ],
        },
      },
    },
    /** GetCollectionByName returns a collection by name. */
    getCollectionByName: {
      name: "GetCollectionByName",
      requestType: GetCollectionByNameRequest,
      requestStream: false,
      responseType: GetCollectionByNameResponse,
      responseStream: false,
      options: {},
    },
    /** CreateCollection creates a collection. */
    createCollection: {
      name: "CreateCollection",
      requestType: CreateCollectionRequest,
      requestStream: false,
      responseType: CreateCollectionResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          578365826: [
            new Uint8Array([
              33,
              58,
              10,
              99,
              111,
              108,
              108,
              101,
              99,
              116,
              105,
              111,
              110,
              34,
              19,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              99,
              111,
              108,
              108,
              101,
              99,
              116,
              105,
              111,
              110,
              115,
            ]),
          ],
        },
      },
    },
    /** UpdateCollection updates a collection. */
    updateCollection: {
      name: "UpdateCollection",
      requestType: UpdateCollectionRequest,
      requestStream: false,
      responseType: UpdateCollectionResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          8410: [
            new Uint8Array([
              22,
              99,
              111,
              108,
              108,
              101,
              99,
              116,
              105,
              111,
              110,
              44,
              117,
              112,
              100,
              97,
              116,
              101,
              95,
              109,
              97,
              115,
              107,
            ]),
          ],
          578365826: [
            new Uint8Array([
              49,
              58,
              10,
              99,
              111,
              108,
              108,
              101,
              99,
              116,
              105,
              111,
              110,
              26,
              35,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              99,
              111,
              108,
              108,
              101,
              99,
              116,
              105,
              111,
              110,
              115,
              47,
              123,
              99,
              111,
              108,
              108,
              101,
              99,
              116,
              105,
              111,
              110,
              46,
              105,
              100,
              125,
            ]),
          ],
        },
      },
    },
    /** DeleteCollection deletes a collection by id. */
    deleteCollection: {
      name: "DeleteCollection",
      requestType: DeleteCollectionRequest,
      requestStream: false,
      responseType: DeleteCollectionResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          8410: [new Uint8Array([2, 105, 100])],
          578365826: [
            new Uint8Array([
              26,
              42,
              24,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              99,
              111,
              108,
              108,
              101,
              99,
              116,
              105,
              111,
              110,
              115,
              47,
              123,
              105,
              100,
              125,
            ]),
          ],
        },
      },
    },
  },
} as const;

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin ? T
  : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
  : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
  : Partial<T>;

function toTimestamp(date: Date): Timestamp {
  const seconds = date.getTime() / 1_000;
  const nanos = (date.getTime() % 1_000) * 1_000_000;
  return { seconds, nanos };
}

function fromTimestamp(t: Timestamp): Date {
  let millis = (t.seconds || 0) * 1_000;
  millis += (t.nanos || 0) / 1_000_000;
  return new Date(millis);
}
